<%@page import="com.hhit.collaborative_learning.utils.Utils"%>
<%@page import="com.mysql.jdbc.StringUtils"%>
<%@page
	import="com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql"%>
<%@page import="com.hhit.collaborative_learning.entity.BlogPage"%>
<%@page import="com.hhit.collaborative_learning.entity.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String currentPageStr = request.getParameter("currentPage");
	String userId=Utils.getCookieValue("userId", request);
	PublicDaoImplMySql dao = new PublicDaoImplMySql();
	if(!StringUtils.isNullOrEmpty(userId)){
		BlogPage blogPage = dao.getBlogByUserIdTypeIsDelete(Integer.parseInt(userId),
				"0", "1", currentPageStr);
		request.setAttribute("blogPage", blogPage);
	}
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="Stylesheet" href="<%=basePath%>css/main.css" />
<!--new top-->
<link rel="stylesheet" href="<%=basePath%>css/index.css">
<!--new top-->

<script type="text/javascript" src="<%=basePath%>js/jquery.js"></script>
<script type="text/javascript" src="<%=basePath%>js/csdn.js"></script>
<script type="text/javascript" src="<%=basePath%>js/master.js"></script>
<script type="text/javascript">
// 	var statichost = "http://static.blog.csdn.net";
	function deleteCompletely(blogId){
	if(confirm("删除文章将不可恢复，是否继续？")){
		$.get("<%=basePath%>ManageBlogServlrt?action=3&blogId="+blogId,function(data,status){
				location.href="<%=basePath%>learning/deleted.jsp";
			});
		}
	}
</script>


<script type='text/javascript' src='<%=basePath%>js/postlist.js'></script>
</head>

<body>
	<!--new top-->
	<!--     <script id="toolbar-tpl-scriptId" fixed="true" prod="blog" skin="black" domain = "http://blog.csdn.net" src="http://static.csdn.net/public/common/toolbar/js/html.js" type="text/javascript"></script> -->
	<!--new top-->
	<div id="wrap">

		<div class="head">
			<div style="float:right; margin-top:20px; color:Red;"></div>
		</div>

		<div class="tabs_header">
			<ul id="ul_tab" class="tabs">
				<li><a href="<%=basePath %>learning/bloglist.jsp"><span>文章管理</span></a></li>
				<li><a href="<%=basePath %>learning/manage_comment.jsp"><span>评论管理</span></a></li>
				<li><a href="<%=basePath %>learning/postedit.jsp"><span>发表文章</span></a></li>
				<li><a href="<%=basePath %>learning/draft.jsp"><span>草稿箱</span></a></li>
				<li><a href="<%=basePath %>learning/deleted.jsp"><span>回收站</span></a></li>
				<li><a href="<%=basePath %>learning/myattention.jsp"><span>我的关系</span></a></li>
				<c:if test="${cookie.cl_blogRight.value ne null}">
				<li><a href="<%=basePath %>learning/myright.jsp"><span>我的权限</span></a></li>
				</c:if>
			</ul>
		</div>
		<script type="text/javascript">
			setTab();
		</script>
		<table id="lstBox" cellspacing="0">
			<tr>
				<th class="tdleft">标题</th>
				<th style="width:50px;">状态</th>
				<th style="width:50px;">阅读</th>
				<th style="width:50px;">评论</th>
				<th style="width:70px;">评论权限</th>
				<th style="width:170px;">操作</th>
			</tr>
			<c:forEach items="${requestScope.blogPage.list }" var="blog">
				<tr>
					<td class='tdleft'><a
						href='<%=basePath %>learning/article.jsp?userId=<%=userId %>&blogId=${blog.blogId}&blogName=${blog.blogName}'
						target=_blank>${blog.blogName}</a><span class='gray'>（${blog.time}）
					</span></td>
					<td></td>
					<td>${blog.readNum}</td>
					<td>${blog.commentNum }</td>
					<td></td>
					<td><a onclick="deleteCompletely('${blog.blogId}');return false;"
						href='#' name=del>彻底删除</a> <!-- 					 | <a href='javascript:void(0);' --> <!-- 					onclick='javascript:return setcat(this,45335513);' class='cat'>分类</a> -->
					</td>
				</tr>
			</c:forEach>
		</table>

		<div class="page_nav">
			<span> ${requestScope.blogPage.count }条数据
									共${requestScope.blogPage.totalPage }页</span>
								<c:if test="${requestScope.blogPage.currentPage>1}">
									<a href="deleted.jsp?currentPage=1">首页</a>
									<a
										href="deleted.jsp?currentPage=${requestScope.blogPage.currentPage-1}">上一页</a>
								</c:if>
								<c:if test="${requestScope.blogPage.pageDiffer>0}">
									<a
										href="deleted.jsp?currentPage=${requestScope.blogPage.pageDiffer*5-4}">...</a>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+1<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+1 }">
											<strong>${requestScope.blogPage.pageDiffer*5+1}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="deleted.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+1}">${requestScope.blogPage.pageDiffer*5+1}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+2<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+2 }">
											<strong>${requestScope.blogPage.pageDiffer*5+2}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="deleted.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+2}">${requestScope.blogPage.pageDiffer*5+2}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+3<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+3 }">
											<strong>${requestScope.blogPage.pageDiffer*5+3}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="deleted.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+3}">${requestScope.blogPage.pageDiffer*5+3}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+4<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+4 }">
											<strong>${requestScope.blogPage.pageDiffer*5+4}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="deleted.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+4}">${requestScope.blogPage.pageDiffer*5+4}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+5<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+5 }">
											<strong>${requestScope.blogPage.pageDiffer*5+5}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="deleted.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+5}">${requestScope.blogPage.pageDiffer*5+5}</a>
										</c:otherwise>
									</c:choose>
								</c:if>
								<c:if
									test="${requestScope.blogPage.totalPage>5 && requestScope.blogPage.pageDiffer<requestScope.blogPage.totalPage/5-1}">
									<a
										href="deleted.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+6}">...</a>
								</c:if>
								<c:if
									test="${requestScope.blogPage.currentPage<requestScope.blogPage.totalPage}">
									<a
										href="deleted.jsp?currentPage=${requestScope.blogPage.currentPage+1}">下一页</a>
									<a
										href="deleted.jsp?currentPage=${requestScope.blogPage.totalPage}">尾页</a>
								</c:if>
		</div>
	</div>

</body>
</html>

